<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<%-- Displays a button. The following parameters can be used :
  - id : optional, the button ID.
  - label : the label code for the button
  - type : the type for the button :
      * "submit" : a submit button.
      * "button" : a regular button outside a form.
      * "back" : a back button.
      * "singleInRow" : a submit button in a form row, that is the single one in
            the row. The row is also created.
      * "singleInCol" : a submit button in a form row, whose container that several
            form columns. The row is also created
  - modifier : optional, a key defining a special use for the button (and the
        corresponding icon). Values are :
      * "prev" : a previous action button.
      * "next" : a next action button.
      * "top" : a top action button.
      * "bottom" : a bottom action button.
      * "left" : a left action button.
      * "right" : a right action button.
      * "prev.step" : a go to previous state action button.
      * "next.step" : a go to next state action button.
      * "drop.down" : a drop down action button.
  - small : optional, boolean string value, "true" to display small buttons
  - help : optional, the code for the message to display when the mouse enters the
            button zone. The ID for the button must be set.
  - disabled : optional, boolean string value, "true" to disable the button.
  - name : optional, the name for the button.
  - value : optional, the value for a submit button.
  - onclick : optional, regular HTML param.
  - onmouseover : optional, regular HTML param.
  - onmouseout : optional, regular HTML param.
  - style : optional, regular HTML param.
  - class : optional, regular HTML param.
--%>

<%-- If the button is a the only one in its row, a row container is added --%>
${param.type == 'singleInRow' ? '<div class="row">' : ''}

<%-- If the button is a the only one in its column, a col container is added --%>
${param.type == 'singleInCol' ? '<p class="buttonsForCol">' : ''}

<%-- If the button is a back button, a span container is added --%>
${param.type == 'back' ? '<span class="back">' : ''}

<%-- Computing the type attribute for the button --%>
<c:set var="btType"
  value="${param.type == 'button' || param.type == 'back' ? 'button' : 'submit'}"/>

<%-- The class attribute --%>
<c:set var="class" value="${param.class} ${param.small == 'true' ? 'small ' : ''}"/>
<c:set var="class" value="${class}${param.type == 'singleInRow' ? 'inRow submit' : ''}"/>

<%-- The mouseover attribute --%>
<c:set var="onmouseover" value="${param.onmouseover}"/>

<%-- The mouseout attribute --%>
<c:set var="onmouseout" value="${param.onmouseout}"/>

<%-- The help attribute --%>
<c:if test="${not empty param.help}">
  <spring:theme var="helpMsg" code='${param.help}' javaScriptEscape="true"/>
  <c:set var="onmouseover" value="showInfoBoxById('${param.id}', '${helpMsg}');${onmouseover}"/>
  <c:set var="onmouseout" value="hideInfoBox();${onmouseout}"/>
</c:if>

<%-- The button --%>
<span class="btContainer ${param.type == 'singleInRow' ? 'inRow' : ''}"

  <%-- The onmouseover attribute --%>
  <c:if test="${not empty onmouseover}">
    onmouseover="${onmouseover}"
  </c:if>

  <%-- The onmouseout attribute --%>
  <c:if test="${not empty onmouseout}">
    onmouseout="${onmouseout}"
  </c:if>
>
	<button type="${btType}"

	  <%-- The id attribute --%>
	  <c:if test="${not empty param.id}">
		id="${param.id}"
	  </c:if>

	  <%-- The name attribute --%>
	  <c:if test="${not empty param.name}">
		name="${param.name}"
	  </c:if>

	  <%-- The value attribute --%>
	  <c:if test="${not empty param.value}">
		value="${param.value}"
	  </c:if>

	  <%-- The onclick attribute --%>
	  <c:if test="${not empty param.onclick}">
		onclick="${param.onclick}"
	  </c:if>

	  <%-- The disabled attribute --%>
	  <c:if test="${not empty param.disabled && param.disabled == 'true'}">
		disabled
		<c:set var="class" value="${class} disabled"/>
	  </c:if>

	  <%-- The class attribute --%>
	  <c:if test="${not empty class}">
		class="${class}"
	  </c:if>

	  <%-- The style attribute --%>
	  <c:if test="${not empty param.style}">
		style="${param.style}"
	  </c:if>

	><span class="before"></span><!--
	   --><span class="content">
		<%-- The button icon --%>
		<c:if test="${not empty param.modifier}">
		  <spring:theme var="enabledIconPath" code="button.icon.${param.modifier}"/>
		  <spring:theme var="disabledIconPath" code="button.icon.${param.modifier}.disabled"/>
		  <img alt="icon button" class="enabledImg" src="${imgFolder}button/${enabledIconPath}"/><!--
			 --><img alt="icon button" class="disabledImg" src="${imgFolder}button/${disabledIconPath}"/>
		</c:if>
		<%-- The button label --%>
		<span class="btText"><spring:theme code='${param.label}'/></span>
	  </span>
	</button>
</span>

<%-- If the button is a back button, a span container is added --%>
${param.type == 'back' ? '</span>' : ''}

<%-- If the button is a the only one in its row, a row container is added --%>
${param.type == 'singleInRow' ? '</div>' : ''}

<%-- If the button is a the only one in its column, a col container is added --%>
${param.type == 'singleInCol' ? '</p>' : ''}